package com.letv.core.parser;

import android.text.TextUtils;

import com.alibaba.fastjson.JSON;
import com.letv.core.bean.LetvBaseBean;

/**
 * 全局解析
 * 
 * @author zhuqiao
 *
 */
public class LetvNormalParser<T extends LetvBaseBean> extends LetvBaseParser<T, String> {

    public LetvNormalParser() {
        this(0);
    }

    public LetvNormalParser(int from) {
        super(from);
    }

    @Override
    protected T parse(String data) throws Exception {
        if (mClz == null || TextUtils.isEmpty(data)) {
            return null;
        }

        // 默认用gson解析
        return JSON.parseObject(data.toString(), mClz);
    }

    @Override
    protected boolean canParse(String data) {
        return !TextUtils.isEmpty(data);
    }

    @Override
    protected String getData(String data) throws Exception {
        return data;
    }

}
